/*
 * 组件注释
 * @Author: machinist_wq
 * @Date: 2022-05-03 12:50:21
 * @LastEditors: machinist_wq
 * @LastEditTime: 2022-06-30 10:16:36
 * @Description: 本地环境配置
 * 人生无常！大肠包小肠......
 */
const path = require("path");
const webpack = require("webpack");
const webpackConfigBase = require("./webpack.base.config");
const { merge } = require("webpack-merge");

function resolve(relatedPath) {
  return path.join(__dirname, relatedPath);
}

const webpackConfigDev = {
  mode: "development",
  output: {
    // filename: "[chunkhash:10][name].index.js",
    filename: "[name].index.js",
    path: resolve("../dist"),
    publicPath: "auto",
    clean: true,
  },
  // devtool: "eval-cheap-module-source-map",
  devtool: "eval-source-map",

  devServer: {
    open: true,
    host: "localhost",
    port: 8080,
    compress: true,
    static: {
      directory: path.join(__dirname, "/"),
    },
    client: {
      overlay: {
        errors: true,
        warnings: false,
      },
    },
    historyApiFallback: true, // 配合BrowserRouter使用
  },
  plugins: [new webpack.HotModuleReplacementPlugin()],
};

module.exports = merge(webpackConfigBase, webpackConfigDev);
